<template>
	<view class="">
		<view class="texinput">
			<input type="text" v-model="userInfo.nickname" />
		</view>
		<view class="istext">{{$t('userinfo.name3')}}</view>
		<!-- <view class="texinput">
			<input type="text" v-model="userInfo.address" />
		</view>
		<view class="istext">{{$t('user.name90')}}</view> -->
		<view class="rebtn" @click="confirm">{{$t('user.name38')}}</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				userInfo:{}
			}
		},
		onLoad(option) {
			uni.setNavigationBarTitle({
				title: option.name
			})
			this.$fun.ajax.post('user/index', {}).then(res => {
				if (res.code == 1) {
					this.userInfo = res.data
				}
			})
		},
		methods: {
			//提交修改
			async confirm() {
				const that =this
				const {
					userInfo,
				} = this;
				if (!userInfo.avatar && userInfo.avatar.slice(0, 10) != 'data:image') {
					this.$fun.msg(this.$t('user.name29'));
					// this.$refs.confirmBtn.stop();
					return;
				}
				if (!userInfo.nickname) {
					this.$fun.msg(this.$t('user.name27'));
					// this.$refs.confirmBtn.stop();
					return;
				}
				let userDate = {
					avatar: userInfo.avatar,
					nickname: userInfo.nickname,
				}
				const res = await this.$fun.ajax.post('/user/profile',{ ...userDate
				}).then(res => {
					if (res.code == 1) {
						this.$fun.msg(this.$t('user.name30'))
						setTimeout(()=>{
							that.$fun.jump('/pages/user/user',3)
						},1200)
					}
				})
			},
		}
	}
</script>

<style lang="scss">
.texinput{
	width: 630rpx;
	margin: 40rpx auto 18rpx;
	border-bottom: 1rpx solid #00A3FF;
	input{
		width: 100%;
		height: 80rpx;
		border-radius: 10rpx;
		padding-left: 20rpx;
	}
}
.istext{
	font-weight: 400;
	font-size: 24rpx;
	color: #232323;
	width: 630rpx;
	margin: 0rpx auto;
}
.rebtn{
	width: 630rpx;
	height: 80rpx;
	background: #00A3FF;
	border-radius: 30rpx;
	font-size: 28rpx;
	color: #FFFFFF;
	line-height: 80rpx;
	text-align: center;
	margin: 50rpx auto;
}
</style>
